export class EffectManager {
  constructor() {
    this.list = [];
  }

  static getInstance() {
    if (!this.instance) {
      this.instance = new EffectManager();
    }
    return this.instance;
  }

  // 添加要做动效的实例对象
  addObj(obj) {
    this.list.push(obj);
  }

  tickForEach(t) {
    // t: 将来渲染循环传过来的毫秒级别数值
    this.list.forEach((obj) => {
      obj.onTick(t);
    });
  }

  // 移除指定物体，不参与动效
  removeObj(obj) {
    let index = this.list.findIndex((target) => target === obj);
    this.list.splice(index, 1);
  }
}
